<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>search article</title>
<style type="text/css">
.articleTable {
	width:640px;
	border-top:1px dashed #cccccc;
	overflow:hidden;
}</style>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.js"></script>
<script type="text/javascript">
function Search(){
	this.articleSearchUrl="/wizard/search/article.html";
	this.userSearchUrl="/wizard/search/user.html";
	this.userSearchRefineUrl="/wizard/search/user/refine.html";
	this.searchArticle=function(){
		var articleSearchKey=document.getElementById("articleSearchKey").value;
		if(articleSearchKey&&articleSearchKey!=""){
			var url=this.articleSearchUrl;
			var data="query="+articleSearchKey;
			var procArticleData=this.procArticleData; 
			document.getElementById("searchArticlesDiv").innerHTML="";
			$.ajax({
				url: url,
				data:data,
				type : "POST",
				dataType:"json",
				contentType: "application/x-www-form-urlencoded; charset=utf-8", 
				success : function(msg){
					procArticleData(msg.data);
				}
			});
		}
	};
	this.procArticleData=function(articles){
		var searchArticles=document.getElementById("searchArticlesDiv");
		for(var i=0;i<articles.length;i++){
			var article= articles[i];
			var innerHTML="";
			innerHTML+="<table class=\"articleTable\">";
			innerHTML+="<tr><td><a class=\"articleTitleA\" href=\"http://localhost:8080/skyline/article/view/"+article.id+".html\" targert=\"_blank\">"+article.title+"</a></td></tr>";
			innerHTML+="<tr><td>来自:<a href=\"http://localhost:8080/skyline\">"+article.ownerNickname+"</a>/";
			innerHTML+="<a href=\"http://localhost:8080/skyline/article/list/user/"+article.ownerId+".html\">日志分类</a>/";
			innerHTML+="<a href=\"http://localhost:8080/skyline/article/list/category/"+article.categoryId+".html\">"+article.categoryName+"</a>/</td></tr>";
			innerHTML+="<tr><td>"+article.digest+"</td></tr></table>";
			searchArticles.innerHTML+=innerHTML;
		}
	};
}
var search=new Search();
</script>
</head>
<body>
<input type="text" name="articleSearchKey" id="articleSearchKey"> <input type="button" onclick="search.searchArticle()" value="搜索">
<div id="searchResultDiv">
<div id="searchArticlesDiv">
</div>
</div>
</body>
</html>